{
  "metadata" : {
    "name" : "Streaming Example",
    "user_save_timestamp" : "2014-12-23T00:59:40.737Z",
    "auto_save_timestamp" : "2014-12-23T00:59:01.720Z",
    "language_info" : {
      "name" : "scala",
      "file_extension" : "scala",
      "codemirror_mode" : "text/x-scala"
    },
    "trusted" : true,
    "customLocalRepo" : null,
    "customRepos" : null,
    "customDeps" : null,
    "customImports" : null,
    "customArgs" : null,
    "customSparkConf" : null
  },
  "cells" : [ {
    "metadata" : {
      "trusted" : true,
      "input_collapsed" : false,
      "collapsed" : false,
      "id" : "3653A681207042AAAAF25153558F7576"
    },
    "cell_type" : "code",
    "source" : "import org.apache.spark.streaming.{StreamingContext, Duration}\nval streaming = new StreamingContext(sparkContext, Duration(1000))",
    "outputs" : [ ]
  }, {
    "metadata" : {
      "trusted" : true,
      "input_collapsed" : false,
      "collapsed" : false,
      "id" : "AB42D489520B46BCA0AA985E9C505105"
    },
    "cell_type" : "code",
    "source" : "import org.apache.spark.streaming.dstream.ConstantInputDStream\nval stream  = new ConstantInputDStream(\n                streaming, \n                sparkContext.makeRDD(Seq.fill(1000)(() => scala.util.Random.nextInt(1000)))\n              )",
    "outputs" : [ ]
  }, {
    "metadata" : {
      "trusted" : true,
      "input_collapsed" : false,
      "collapsed" : false,
      "id" : "3129709950FF4AA886EA5F644370FFCB"
    },
    "cell_type" : "code",
    "source" : "val concrete = stream.map(_())",
    "outputs" : [ ]
  }, {
    "metadata" : {
      "trusted" : true,
      "input_collapsed" : false,
      "collapsed" : false,
      "id" : "2625ADE1FAAE4B62B770BFB873207195"
    },
    "cell_type" : "code",
    "source" : "import notebook._, front._, widgets._\nimport notebook.JsonCodec._\nimport play.api.libs.json._\n\nval ts = TimeseriesChart(Seq((System.currentTimeMillis.toDouble, 0.0)))\n\nconcrete.foreachRDD { rdd => \n  val sum = rdd.reduce(_+_)\n  ts.addAndApply(Seq((System.currentTimeMillis.toDouble, sum.toDouble)))\n}\nstreaming.start\nts",
    "outputs" : [ ]
  }, {
    "metadata" : {
      "trusted" : true,
      "input_collapsed" : false,
      "collapsed" : false,
      "id" : "8C82F7BECA9F4868AF14F64DDCC70E88"
    },
    "cell_type" : "code",
    "source" : "import scala.concurrent._\nimport scala.concurrent.ExecutionContext.Implicits.global\nFuture { Thread.sleep(30000) ; streaming.stop() }\n ",
    "outputs" : [ ]
  } ],
  "nbformat" : 4
}